package receiver;

import android.app.Activity;
import android.app.PictureInPictureParams;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.text.TextUtils;
import android.util.Rational;

public class ReturnDesktopReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent != null && intent.getAction().equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)){
            String reason = intent.getStringExtra("reason");
            if ( !TextUtils.isEmpty(reason) && (reason.equals("homekey") || reason.equals("recentapps"))){
                // android 8.0 之后才开启画中话模式
                if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O ){
                    // 创建画中画模式的参数构造器
                    PictureInPictureParams.Builder builder = new PictureInPictureParams.Builder();
                    Rational rational = new Rational(10,5);
                    builder.setAspectRatio(rational);
                }
            }
        }
    }
}
